package com.gulimall.product.domain.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.List;

import com.gulimall.common.valid.AddGroup;
import com.gulimall.common.valid.ListValid;
import com.gulimall.common.valid.UpdateGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * <p>
 * 商品三级分类
 * </p>
 *
 * @author 坤哥
 * @since 2025-08-25
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("pms_category")
public class Category implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 分类id
     */
    @TableId(value = "cat_id", type = IdType.AUTO)
    @Null(message = "新增时不能设置id",groups = AddGroup.class)
    @NotNull(message = "修改时必须设置id",groups = UpdateGroup.class)
    private Long catId;

    /**
     * 分类名称
     */
    @TableField("name")
    @NotBlank(message = "name不能为空",groups = AddGroup.class)
    private String name;

    /**
     * 父分类id
     */
    @TableField("parent_cid")
    private Long parentCid;

    /**
     * 层级
     */
    @TableField("cat_level")
    private Integer catLevel;

    /**
     * 是否显示[0-不显示，1显示]
     */
    @TableLogic(value = "1",delval = "0")//1表示不删除
    @TableField("show_status")
    @ListValid(vals={0,1},groups = {AddGroup.class,UpdateGroup.class})
    private Integer showStatus;

    /**
     * 排序
     */
    @TableField("sort")
    private Integer sort;

    /**
     * 图标地址
     */
    @TableField("icon")
    private String icon;

    /**
     * 计量单位
     */
    @TableField("product_unit")
    private String productUnit;

    /**
     * 商品数量
     */
    @TableField("product_count")
    private Integer productCount;

    /**
     * 子分类商品
     */
    @TableField(exist = false)//表示这个字段不存在于数据库，但是能在json中展示
    private List<Category> children;

}
